"""firstDjango URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from index.views import user
from index.views import books, comment, comment_like
from index.views.upload import upload_image
from index.views import clip

user_patterns = [
    path('login', user.login),
    path('register', user.register),
    path('extendUserInfo', user.add_ExtendUserInfo),
    path('getMyInfo', user.getUserInfo),
    path('updateMyInfo', user.updateUserInfo),
    path('logoff', user.logoff),
    path('modifyPassword', user.modify_password),
    path('verifyPassword', user.verify_password)
]
book_patterns = [
    path('add', books.add_book),
    path('delete', books.delete_book),
    path('update', books.update_book_info),
    path('getBookByNumber', books.getBook_by_number),
    path('getBookByTitle', books.getBook_by_title),
    path('fetch_books', books.fetch_books),

    path('addPub', books.add_pub),
    path('deletePub', books.delete_pub),

    path('addAuthor', books.add_author),
    path('deleteAuthor', books.delete_author),
    path('updateAuthor', books.update_author),
]

comment_patterns = [
    path('publish', comment.publish_comment),  # 发表评论
    path('delete', comment.delete_comment),  # 删除评论
    path('update', comment.update),
    path('fetchByBookId', comment.fetch_comments),  # 查询数据的评论列表
    path('like', comment_like.like),
    path('myLikes', comment_like.my_likes),
    path('fetchMyComments', comment.fetch_my_comments)

]

clip_patterns = [
    path('load_connect', clip.load_connect),
    path('set_connect', clip.set_connect)
]

api_patterns = [
    path('user/', include(user_patterns)),
    path('book/', include(book_patterns)),
    path('comment/', include(comment_patterns)),
    path('silk/', include('silk.urls', namespace='silk')),
    path('upload', upload_image),
    path('clip/', include(clip_patterns))
]

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include(api_patterns))
]
